﻿using System;
using System.Security.Cryptography;

namespace TSites.Service.Common
{
	public class RNGCrypRandom : IRandom
	{
		#region IRandomString Members

		public string Generate(int size)
		{
			return Convert.ToBase64String(GetBytes(size));
		}

		public byte[] GetBytes(int size)
		{
			byte[] buffer = new byte[size];
			new RNGCryptoServiceProvider().GetBytes(buffer);

			return buffer;
		}

		#endregion
	}
}
